home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The World of Computer Software
/
The World of Computer Software.iso
/
vsc92nov.zip
/
Primitive.c
< prev
next >
Wrap
C/C++ Source or Header
|
1992-11-02
|
2KB
|
94 lines
/*
* Primitive.c -- Implementation of Scheme Primitives
*
* (C) m.b (Matthias Blume), Mar 1992, HUB/Ger
*/
# ident "@(#)Primitive.c (C) M.Blume, Humboldt-Uni Berlin, 1.2"
# include <stdio.h>
# include "storext.h"
# include "Primitive.h"
# include "identifier.h"
# include "type.h"
# include "except.h"
/*
* There is a file "builtins.tab", where each built-in function
* should be registered by means of an entry of the form
* BUILTIN (name-of-function, name-of-cont-function, name-string)
*/
# include "builtins.tab"
static
ScmPrimitive primitive_array [] = {
# define BUILTIN_CONT(f,c,n,a) { ScmType (Primitive), f, c, 0, n, a },
# define BUILTIN(f,n,a) { ScmType (Primitive), f, NULL, 0, n, a },
# include "builtins.tab"
# undef BUILTIN
# undef BUILTIN_CONT
};
# define DIM(x) (sizeof x / sizeof x[0])
static
void dump (void *vprim, FILE *file)
{
dump_ul ((ScmPrimitive *)vprim - primitive_array, file);
}
static
void *restore_init (FILE *file)
{
unsigned short num;
num = restore_ul (file);
return (void *) (primitive_array + num);
}
static
void display (void *vprim, putc_proc pp, void *cd)
{
ScmPrimitive *prim = vprim;
putc_string ("#<Primitive ", pp, cd);
putc_string (prim->name, pp, cd);
(* pp) ('>', cd);
}
static
void init_module (void)
{
unsigned i;
for (i = 0; i < DIM (primitive_array); i++)
primitive_array[i].seq_num = i;
}
static
struct scheme_od_extension ext = {
display, display,
NULL, NULL, /* must coincide to be equal */
};
OD_VECTOR (ScmPrimitive_od_vector,
0, /* these are fixed objects, there can be only one! */
NULL,
do_nothing_on_subs,
PRIMITIVE_IDENTIFIER,
dump, restore_init, NULL,
init_module,
NULL, NULL,
&ext
);
void *GetScmPrimitive (unsigned long seq_num)
{
return (void *) (seq_num < DIM (primitive_array)
? primitive_array + seq_num
: NULL);
}